<?php
require_noce('Zend/Config/Xml.php');
class messageModel
{
	static $dbLink,$messageT;
	/*
	 * 建立数据库链接
	 */
	public function __construct()
	{
		$dbInfo = new Zend_Config_Xml('./config/config.xml','database');
		self::$dbLink = Zend_DB::factroy('PDO_MYSQL',$dbInfo->toArray());
		self::$dbLink->query('set names utf8');
		Zend_Db_Table::setDefaultAdapter(self::$dbLink);
		self::$messageT= new message();
	}
	/*
	 * 发送一条消息@para为一数组
	 * Array('message_title'=>消息标题,'message_toid'=>给谁的消息,'message_uid'=>谁发的,
	 * 					'message_content'=>消息内容,)
	 */
	public function sendAMessage($para)
	{
		return self::$messageT->insert($para);
	}
	/*
	 * 查看消息@para  消息id
	 * 改消息的是否阅读字段值
	 */
	public function lookAMessage($para)
	{
		self::$messageT->update();
		return self::$messageT->fetchAll("message_id=$para")->toArray();
	}
	/*
	 * 消息列表@para为用户id
	 * 已查看的和未查看的要分开
	 */
	public function getMessageList($para,$page)
	{
		return self::$messageT->fetchAll("message_toid=$para")->toArray();
	}
}
?>